package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 合同审批状态 枚举类
 * 待审批  | 审批通过 | 审批驳回
 *
 * @author 合房源码
 */

@Getter
@AllArgsConstructor
public enum ContractApproveEnum {
    NO_AUDIT_REQUITED("notReview","无需审核"),
    PENDING("pending", "待审批"),
    PASS("pass", "审批通过"),
    REJECT("reject", "审批驳回"),
    ;
    //编码
    private final String code;
    //信息
    private final String msg;

    private static final Map<String, ContractApproveEnum> enumMap = new HashMap<>();

    static {
        ContractApproveEnum[] values = ContractApproveEnum.values();
        for (ContractApproveEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }

    public static ContractApproveEnum getEnum(String num) {
        return enumMap.get(num);
    }

    public static ContractApproveEnum getContractApproveEnumByCode(String code) {
        ContractApproveEnum[] contractNodeEnums = values();
        for (ContractApproveEnum contractNodeEnum : contractNodeEnums) {
            if (contractNodeEnum.code.equals(code)) {
                return contractNodeEnum;
            }
        }
        return null;
    }

}
